Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rds): add support for database instances #2187

Merged
merged 42 commits into from
May 31, 2019
Merged

Conversation

jogold
Copy link
Contributor

@jogold jogold commented Apr 5, 2019

Add support for database instances.

Specific classes are exposed for a source database instance (DatabaseInstance), an instance created from a snapshot (DatabaseInstanceFromSnapshot) and a read replica instance (DatabaseInstanceReadReplica).

Add construct for option groups and refactor parameter groups.

Add basic support for instance event rules.

Integration with Secrets Manager and secret rotation.

Closes #2075
Closes #1693


Pull Request Checklist

  • Testing
    • Unit test added (prefer not to modify an existing test, otherwise, it's probably a breaking change)
    • CLI change?: coordinate update of integration tests with team
    • cdk-init template change?: coordinated update of integration tests with team
  • Docs
    • jsdocs: All public APIs documented
    • README: README and/or documentation topic updated
  • Title and Description
    • Change type: title prefixed with fix, feat will appear in changelog
    • Title: use lower-case and doesn't end with a period
    • Breaking?: last paragraph: "BREAKING CHANGE: <describe what changed + link for details>"
    • Issues: Indicate issues fixed via: "Fixes #xxx" or "Closes #xxx"
  • Sensitive Modules (requires 2 PR approvers)
    • IAM Policy Document (in @aws-cdk/aws-iam)
    • EC2 Security Groups and ACLs (in @aws-cdk/aws-ec2)
    • Grant APIs (only if not based on official documentation with a reference)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.

@jogold jogold requested a review from a team as a code owner April 5, 2019 15:57
@jogold jogold mentioned this pull request Apr 8, 2019
4 tasks
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just started the review of this huge piece of work. Looks great. More to review.

@@ -45,33 +45,85 @@ By default, the master password will be generated and stored in AWS Secrets Mana
Your cluster will be empty by default. To add a default database upon construction, specify the
`defaultDatabaseName` attribute.

### Starting an Instance Database
To set up a instance database, create an instance of `DatabaseInstance`. You must
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the terminology "define a DatabaseInstance" (instead of "create an instance").

rule.addEventPattern({
source: [ 'aws.rds' ],
resources: [
this.node.stack.formatArn({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we expose instanceArn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

*/
export interface DatabaseInstanceNewProps {
/**
* The name of the compute and memory capacity classes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a sensible default here?

/**
* Specifies if the database instance is a multiple Availability Zone deployment.
*
* @default false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the implications of making this true by default? Wouldn't that be a better practice?

Copy link
Contributor Author

@jogold jogold Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if possible I would like to a have production defaults in this construct: db.r5.large, multi az, 1000 IOPS, 100 GiB, encryption enabled with default master key, 7 days backup, enhanced monitoring, no auto minor version upgrade (the console experience when selecting Production).

Looking at the discussion we had here #2063 (comment) and the issue you raised with implicit costs to customer, would you be ok to accept these production defaults?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eladb any update on whether production defaults are acceptable for this construct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting conversation, and I wonder if this would be something we run into in the future, sort of "presets". The RDS console definitely demonstrates that there is value in allowing people to being configuring their new database from a predefined set of options that are tailored for a use case.

Maybe we should have a similar experience:

new rds.DatabaseInstance(this, 'instance', rds.DatabaseInstancePresets.production());
// or, override some value:
new rds.DatabaseInstance(this, 'instance', rds.DatabaseInstancePresets.production({
  multiAz: false
}));

Something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you specify mandatory properties like engine and masterUsername with this API? Spread the preset and add those properties?

{
  ...rds.DatabaseInstancePresets.production(),
  masterUsername: '...'
}

* The number of I/O operations per second (IOPS) that the database provisions.
* The value must be equal to or greater than 1000.
*
* @default no iops
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does no IOPs mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually setting provisioned IOPS. The default behavior is you don't get provisioned (aka guaranteed) IOPS... This can incur additional cost when enabled.

So yeah, I guess the phrasing can be improve to this effect. I think copying the documentation from RDS/CloudFormation should be best.

/**
* The number of CPU cores and the number of threads per core.
*
* @default no processor features
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the default?

*
* @default false
*/
readonly enableIAMDatabaseAuthentication?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sufficient to just call this iamAuth or something more concise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go for iamAuthentication

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, there should also be a grant method to provide permissions there. And this is tricky because it requires to know the instance's Resource ID, which I don't reckon is surfaced by CloudFormation (aka requires CustomResource 😔)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aka requires CustomResource

Another use case for #1850

/**
* The daily time range during which automated backups are performed.
*
* @default no preference
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean random time range or no backup?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"no preference" means AWS chooses for you.

/**
* The storage type.
*
* @default GP2
Copy link
Contributor Author

@jogold jogold Apr 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct: the current implementation defaults to IOPS not GP2. Waiting for a reply on production defaults to update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be updated (wrong default value documented). @eladb any feedback on using production defaults here ? See #2187 (comment)

@jogold
Copy link
Contributor Author

jogold commented May 30, 2019

Added a commit to close #2075 and #1693

@rix0rrr rix0rrr merged commit b864041 into aws:master May 31, 2019
@jogold jogold mentioned this pull request Jun 7, 2019
4 tasks
@jogold jogold deleted the rds-instance branch June 13, 2019 13:20
This was referenced Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to set instance parameter group on instances in rds.DatabaseCluster
4 participants